﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.Composition;
using Core.BusinessLogic.Interfaces;
using Core.Common;
using Core.DataAccess.IRepositories;
using Core.DataAccess;

namespace Core.BusinessLogic
{
    [Export(typeof(IMessageService))]
    public class MessageService : IMessageService
    {
        [Import]
        private IMessageRepository _messageRepository;

        public MessageService()
        {
            MEFManager.Compose(this);
        }

        public int CountMessages(int accountID)
        {
            return _messageRepository.CountMessages(accountID);
        }

        public void SaveMessage(DataAccess.Message mesage)
        {
            _messageRepository.SaveMessage(mesage);
        }

        public List<Message> GetMessagesByAccountID(int accountID)
        {
            return _messageRepository.GetMessagesByAccountID(accountID);
        }

        public void UpdateMessageIsRead(Message msg)
        {
            _messageRepository.UpdateMessageIsRead(msg);
        }

        public void DeleteMessageByAccountID(int accountID, int friendID)
        {
            _messageRepository.DeleteMessageByAccountID(accountID, friendID);
        }
    }
}
